package com.wanlian.netty.File.msg.down;

import com.wanlian.File.NetFileInfo;
import com.wanlian.json.JsonStringUtil;
import com.wanlian.netty.File.model.FileHead;
import com.wanlian.netty.File.msg.FileBaseMsg;
import com.wanlian.netty.model.ResultInfo;
import com.wanlian.netty.msg.MsgType;

/**
 * 下载确认信息
 */
public class FilePeerDownRspMsg extends FileBaseMsg {
    private FileHead fileHead;

    public FilePeerDownRspMsg() {
        this.setType(MsgType.DEVICE_FILE_DOWNLOAD_RSP);
        this.fileHead = new FileHead();
    }

    public FilePeerDownRspMsg(NetFileInfo netFileInfo) {
        this.setType(MsgType.DEVICE_FILE_DOWNLOAD_RSP);
        this.fileHead = new FileHead();
        this.fileHead.setSize(netFileInfo.getSize());
        this.fileHead.setFileName(netFileInfo.getFileName());
        this.fileHead.setOffset(netFileInfo.getCurrentIndex());
        this.fileHead.setTotal(netFileInfo.getTotalSize());
        this.setContent(JsonStringUtil.writeValueAsString(this.fileHead));
        this.setData(netFileInfo.getBytes());
    }
}
